#!/usr/bin/env Python
# -*- coding: utf-8 -*-

"""
使用requests请求代理服务器
请求http和https网页均适用
"""

import requests

# 提取代理API接口，获取1个代理IP
api_url = ""


proxy_ip = requests.get(api_url).text

username = ""
password = " "
proxies = {
    "http": "http://%(user)s:%(pwd)s@%(proxy)s/" % {"user": username, "pwd": password, "proxy": proxy_ip},
    "https": "http://%(user)s:%(pwd)s@%(proxy)s/" % {"user": username, "pwd": password, "proxy": proxy_ip}
}


target_url = "https://dev.kdlapi.com/testproxy"

response = requests.get(target_url, proxies=proxies)


if response.status_code == 200:
    print(response.text)